from appium import webdriver
import time

desired_caps = dict()
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = 'moniqi'
# desired_caps['appPackage'] = 'com.android.settings'
# desired_caps['appActivity'] = '.Settings'
desired_caps['appPackage'] = 'com.android.contacts'
desired_caps['appActivity'] = '.activities.PeopleActivity'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

driver.find_element_by_id("com.android.contacts:id/floating_action_button").click()
driver.find_element_by_xpath("//*[@text='本地保存']").click()
driver.find_element_by_xpath("//*[@text='姓名']").send_keys("ls")
driver.find_element_by_xpath("//*[@text='电话']").send_keys("13411110000")


time.sleep(3)
driver.quit()
